cd "/Users/dawnshen/Dropbox/Yinzhi/MassShootings/Superbowl"
****************************
****************************
** Superbowl city
****************************
****************************

use "Superbowl_city_working_analysisfile", clear
*************************************************************************	
* Generate indicators of interview timing 
*************************************************************************	
drop if date==sbdate //Drop obs if being interviewed on the SB day

gen bf28=0
replace bf28=1 if date-sbdate>=-28 & date-sbdate<=-1 //interviewed in the four weeks before the incident - control group
gen r_af1=0 //interviewed one day after the incident
replace r_af1=1 if date-sbdate==1
gen bf28_1=0
replace bf28_1=1 if r_af1==1 | bf28==1  //interviewed one day after the incident or in the control group


foreach i in 2 4 7 14 21 28 {
gen r_af`i'=0
replace r_af`i'=1 if date-sbdate>=`i'-1 & date-sbdate<=`i'+1  //interviewed around i days after the incident

gen bf28_`i'=0
replace bf28_`i'=1 if bf28==1 | r_af`i'==1 //interviewed around i days after the incident or in the control group
replace bf28_`i'=. if date-sbdate>0 & date-sbdate<`i'-1 //remove those interviewed after SB and before i-1 days from the model
}


* # of obs interviewed on the (i-1)th, ith, and (i+1)th day since SB
foreach i in 1 2 4 7 14 21 28 {
tab1 r_af`i', m
}

		

*************************************************************************
** Graph effect size
*************************************************************************

mdesc winner    
gen loser = 0
replace loser = 1 if winner ==0

tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if winner==1
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if loser==1


foreach party in winner loser {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if `party'==1, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`party'", estimates)
matrix rownames emotion_`party' = `rownames'
matrix colnames emotion_`party' = Coef LL UL
matprint emotion_`party', d(3)
}

coefplot (matrix(emotion_winner[,1]), ci((emotion_winner[,2] emotion_winner[,3])) msize(small) msymbol(circle) label("Winner")) (matrix(emotion_loser[,1]), ci((emotion_loser[,2] emotion_loser[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("Loser")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.5(0.1).5, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.5(0.1).5)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Superbowl_citybfaf_3day_controls_byemotion_bywinner.pdf, replace



****************************		
****************************
** Superbowl State
****************************
****************************

use "Superbowl_state_working_analysisfile", clear
*************************************************************************	
* Generate indicators of interview timing 
*************************************************************************	
drop if date==sbdate //Drop obs if being interviewed on the SB day

gen bf28=0
replace bf28=1 if date-sbdate>=-28 & date-sbdate<=-1 //interviewed in the four weeks before the incident - control group
gen r_af1=0 //interviewed one day after the incident
replace r_af1=1 if date-sbdate==1
gen bf28_1=0
replace bf28_1=1 if r_af1==1 | bf28==1  //interviewed one day after the incident or in the control group


foreach i in 2 4 7 14 21 28 {
gen r_af`i'=0
replace r_af`i'=1 if date-sbdate>=`i'-1 & date-sbdate<=`i'+1  //interviewed around i days after the incident

gen bf28_`i'=0
replace bf28_`i'=1 if bf28==1 | r_af`i'==1 //interviewed around i days after the incident or in the control group
replace bf28_`i'=. if date-sbdate>0 & date-sbdate<`i'-1 //remove those interviewed after SB and before i-1 days from the model
}


* # of obs interviewed on the (i-1)th, ith, and (i+1)th day since SB
foreach i in 1 2 4 7 14 21 28 {
tab1 r_af`i', m
}

*************************************************************************
** Graph effect size
*************************************************************************

mdesc winner    
gen loser = 0
replace loser = 1 if winner ==0

tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if winner==1
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if loser==1


		
foreach party in winner loser {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if `party'==1, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`party'", estimates)
matrix rownames emotion_`party' = `rownames'
matrix colnames emotion_`party' = Coef LL UL
matprint emotion_`party', d(3)
}

coefplot (matrix(emotion_winner[,1]), ci((emotion_winner[,2] emotion_winner[,3])) msize(small) msymbol(circle) label("Winner")) (matrix(emotion_loser[,1]), ci((emotion_loser[,2] emotion_loser[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("Loser")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.1(0.01).1, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.1(0.01).1)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Superbowl_statebfaf_3day_controls_byemotion_bywinner.pdf, replace




